<!-- 个人资料 -->
<script type="text/javascript" charset="utf-8" src="/uedit/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="https://cdn.staticfile.org/ueditor/1.4.3/ueditor.all.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/uedit/lang/zh-cn/zh-cn.js"></script>
<link rel="stylesheet" href="/css/otherInformation.css">
<link rel="stylesheet" href="/css/othermessageBoard.css">
<div class="main layui-clear" style="width: 100%;margin-bottom: 0;">
	<div class="fly-main layui-clear">
		<div class="wrap clearfix">
			<#include "/apps/user/otheruser/otherusermenu.html">
			<div class="home-right" id="commenttopic">
				<div class="content">
					<ul class="title mobile-display-none">
					<li class="layui-this">留言</li>
					</ul>
					<div class="message-add layui-form">
						<form action="/messageboard/otherSave.html" method="post">
							<input type="hidden" name="userid" value="${curruser.id}"> 
			 				<div class="layui-input-inline" style="margin-bottom: 20px">
					          <textarea id="content" name="content" lay-verify="content|checkContent"  placeholder="请输入内容"  style="height: 80px;"></textarea>
					        </div>							 
					        <div class="layui-input-inline" style="float: right">
					          <button class="layui-btn" id="button-one" lay-submit  lay-filter="formDemo">留言</button>
					          <a href="#" class="layui-btn  layui-hide" style="width: 110px;"  id="button-two">提交...</a>
					        </div>
					        <div style="clear: both"></div>
						</form>
					</div>
					<div class="message-list">
						<#if messageBoardList??>
						<#list messageBoardList.content as list>
							<li>
							<#if list.user.username == user.username>
				        	<!-- pc端帖子头像 -->
				         	<a href="/user/profile.html" class="fly-list-avatar mobile-display-none">
							<img class="head" src="/${list.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null">
							<span>${list.user.username!''}</span>
							 </a>
							 <a href="/user/index.html" class="fly-list-avatar pc-display-none">
							 <img class="head" src="/${list.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null">
							 <span>${list.user.username!''}</span>
							 </a>
							 <#else>
							 <a href="/user/otherUser/${list.user.id}.html" target="_blank" class="fly-list-avatar mobile-display-none">
							 <img class="head" src="/${list.user.fileurl!''}" onerror="this.src='/images/user/default.jpg';this.onerror=null">
							 <span>${list.user.username!''}</span>
							 </a>
							 </#if>
							<label><#if list.user.usertype?? && list.user.usertype == "0">管理员<#else>${list.user.grade.groups}</#if></label>
							<span class="time pc-display-none">${list.createtime?string('yyyy-MM-dd HH:mm')}</span>
							<div>${(list.content)?no_esc}</div>
							<span class="time mobile-display-none">${list.createtime?string('yyyy-MM-dd HH:mm')}</span>
							</li>
						</#list>
						</#if>
					</div>
				</div>
			<div style="text-align: center" class="front-desk">
		        <div class="laypage-main" id="topicpages"></div>
		    </div>
		</div>
	</div>
</div>
<script>

layui.use(['form' ,'laypage'], function(){
  var form = layui.form() ;
  form.verify({
	  checkContent: function(value, item){ 
		  var status = "";
		  if(mobileTopicSign=="pc"){
		  	value = ue.getContentTxt();
		  }
			$.ajax({
				  type:"POST",
				  url:"/checkConent",
				  data: {"content": value},
				  async: false,
				  success:function(data){
					 
					   var result = JSON.parse(data.requestmsg);
					   var resultsType = result.data[0].results[0].label;
					   if(result.data[0].results[0].suggestion!="pass"){
						   switch (resultsType)
							  {
							  case "spam":
								  status='您的内容包含垃圾信息';
							    break;
							  case "ad":
								  status='您的内容包含广告信息';
							    break;
							  case "politics":
								  status='您的内容包含渉政信息';
							    break;
							  case "terrorism":
								  status='您的内容包含暴恐信息';
							    break;
							  case "abuse":
								  status='您的内容包含辱骂信息';
							    break;
							  case "porn":
								  status='您的内容包含色情信息';
							    break;
							  case "flood":
								  status='您的内容包含灌水信息';
							    break;
							  case "contraband":
								  status='您的内容包含违禁信息';
							    break;
							  }
					   }
				  },
				  error:function(data){
					  console.log(data.requestmsg)
				  },
			  })
			  if(status!=""){
				  return status;
			  }
	  },
	  content: function(value, item){ 
		  if(mobileTopicSign=="pc"){
			value = ue.getContent();
		  }
	   	 if(value.length <= 0) {
	        return '请输入正文';
	     }
	  },
	  
	}); 
	form.on('submit(formDemo)', function(data){
		  $("#button-one").addClass("layui-hide");
		  $("#button-two").removeClass("layui-hide").addClass("layui-show");
	    	
	  });
  var laypage = layui.laypage;
	laypage({
	    cont: 'topicpages'
	    ,first:'首页'
	    ,last:'末页'
	    ,pages: ${messageBoardList.totalPages}
	    ,curr:${messageBoardList.number+1}
	    ,skin: '#32c24d'
	    ,skip: true
	    ,jump:function(obj, first){
	    	var curr = obj.curr;
	    	if(!first){
	               location.href = '/user/messageBlock/allList?p=' + curr + "<#if RequestParameters['q']?? && RequestParameters['q'] != ''>&q=${RequestParameters['q']}</#if>";
	    	}
	    }
	});

});
UE.Editor.prototype.placeholder = function (justPlainText) {
	var _editor = this;
	_editor.addListener("focus", function () {
		var localHtml = _editor.getPlainTxt();
		if ($.trim(localHtml) === $.trim(justPlainText)) {
			_editor.setContent(" ");
		}
	});
	_editor.addListener("blur", function () {
		var localHtml = _editor.getContent();
		if (!localHtml) {
			_editor.setContent(justPlainText);
		}
	});
	_editor.ready(function () {
		_editor.fireEvent("blur");
	});
};
if(mobileTopicSign=="pc"){
	var ue = UE.getEditor('content', {
		//这里可以选择自己需要的工具按钮名称
		toolbars: [
			['Source','|', 'undo', 'redo', 'removeformat', 'backcolor', 'formatmatch','|', 'italic', 'underline', 'Bold', 'test',
				'forecolor','|', 'justifyleft', 'justifycenter', 'justifyright','|','insertorderedlist' ,'|',
				'fontfamily', 'fontsize','|',
				 'emotion'
			]
		],
		wordCount: false,					//开启字数统计
		elementPathEnabled : false,
		retainOnlyLabelPasted : true
	});
	//placeholder内容(只能是文本内容)
	ue.placeholder("请输入正文");
}
</script>